<template>
	<view class="layout">
		<view class="navbar">
			<view class="statusbar" :style="{height:statusBarHeight+'px'}"></view>
			<view class="titleBar" :style="{height:titleBarHeight+'px',marginLeft:getLeftIconLeft()+'px'}">
				<view class="title">{{title}}</view>
				<view class="search" @click="goSearch">
					<uni-icons class="icon" type="search" color="#888" size="18"></uni-icons>
					<text class="text">搜索</text>
				</view>
			</view>
		</view>
		<view class="fill" :style="{height:statusBarHeight+titleBarHeight+'px'}"></view>	
	</view>
</template>

<script setup>
	//导入工具类中的方法
	import {getStatusBarHeight,getTitleBarHeight,getLeftIconLeft} from "@/utils/system_info.js"
	//同步获取设备信息
	const statusBarHeight=ref(getStatusBarHeight())
	const titleBarHeight=ref(getTitleBarHeight())
	
	defineProps({
		title:{
			type:String,
			default:'标题内容'
		}
	})
	
	//跳转搜索页面
	function goSearch(){
		uni.navigateTo({
			url:"/pages/search/search"
		})
	}
</script>

<style lang="scss" scoped>
	.layout{
		.navbar{
			// display: flex;
			position: fixed;
			left: 0;
			top: 0;
			z-index: 100;
			width: 100%;
			background-image:
				linear-gradient(
					to bottom,
					rgba(0,0,0,0),
					#fff 400rpx
				),
				linear-gradient(
					to right,
					#beecd8 20%,
					#f4e2d8
				);
			.statusbar{
				// border: 1rpx solid red;
			}
			.titleBar{
				display: flex;
				align-items: center;
				padding: 0 30rpx;
				// border: 1rpx solid green;
				.title{
					font-weight: bold;
					color: $text-font-color1;
					font-size: 50rpx;
				}
				.search{
					display: flex;
					align-items: center;
					margin-left: 30rpx;
					width: 220rpx;
					height: 50rpx;
					border: 1rpx solid #fff;
					border-radius: 60rpx;
					background-color: rgba(255,255,255,0.4);
					color: #999;
					font-size: 28rpx;
					.icon{
						margin-left: 5rpx;
					}
					.text{
						padding-left: 10rpx;
					}
				}
			}
		}
	}
</style>